package com.aspose.cells;

import java.util.HashMap;
import java.util.Iterator;

class zark {
   private zcfw a;
   private zapy b;
   private Worksheet c;
   private zapz d;
   private int e;
   private int f;
   private int g;
   private int h;
   private int i;
   private int j;
   private HashMap k;
   private HashMap l;
   private int m;
   private int n;
   private int o;
   private int p = 255;
   private static final com.aspose.cells.b.c.a.za q = new com.aspose.cells.b.c.a.za(new String[]{"name", "style-name", "print-ranges", "table-column", "table-row", "table-header-rows", "table-header-columns", "table-column-group", "table-row-group", "number-columns-repeated", "default-cell-style-name", "table-cell", "covered-table-cell", "number-rows-repeated", "value-type"});

   zark(zapy var1) {
      this.b = var1;
   }

   private void a() {
      this.i = this.j = -1;
      this.e = this.f = -1;
      this.g = this.h = -1;
      this.l = new HashMap();
      this.k = new HashMap();
   }

   private void b() {
      if (this.c != null) {
         String var1 = "";
         if (this.f != -1) {
            var1 = "$" + (this.e + 1) + ":$" + (this.f + 1);
         }

         if (this.h != -1) {
            if (this.f != -1) {
               var1 = var1 + ",";
            }

            var1 = var1 + "$" + CellsHelper.columnIndexToName(this.g) + ":$" + CellsHelper.columnIndexToName(this.h);
         }

         if (!"".equals(var1)) {
            this.c.getPageSetup().a(var1);
         }

         int var2 = this.n + 255 - this.o;
         double var3 = 64.8D;
         Iterator var5 = this.l.keySet().iterator();

         while(var5.hasNext()) {
            String var6 = (String)var5.next();
            int var7 = (Integer)this.l.get(var6);
            if (var7 > var2) {
               zaps var8 = (zaps)this.b.f.get(var6);
               if (var8 != null) {
                  var3 = var8.a();
               }
            }
         }

         this.d.f = var3;
         this.d.a.getCells().setStandardWidthInch(var3 / 72.0D);
         this.d.a(this.i);
         double var11 = 13.68D;
         var2 = this.n;
         Iterator var12 = this.k.keySet().iterator();

         while(var12.hasNext()) {
            String var13 = (String)var12.next();
            int var9 = (Integer)this.k.get(var13);
            if (var9 > var2) {
               zaqd var10 = (zaqd)this.b.d.get(var13);
               if (var10 != null) {
                  var11 = var10.b();
                  var2 = var9;
               }
            }
         }

         this.d.a.getCells().a = (double)((int)(var11 * 20.0D + 0.5D) & '\uffff');
      }
   }

   private void a(String var1) {
      var1 = com.aspose.cells.b.a.zv.a(var1, this.c.getName() + ".", "");
      var1 = com.aspose.cells.b.a.zv.a(var1, "'" + this.c.getName() + "'.", "");
      var1 = var1.replace(' ', ',');
      var1 = com.aspose.cells.b.a.zv.a(var1, ":.", ":");
      this.c.getPageSetup().setPrintArea(var1);
   }

   void a(zcfw var1) throws Exception {
      this.a = var1;
      this.a();
      String var2 = null;
      String var3 = null;
      if (var1.m()) {
         String var4 = null;

         while(var1.l()) {
            switch(q.a(var1.p().toLowerCase())) {
            case 0:
               var4 = var1.s();
               break;
            case 1:
               var2 = var1.s();
               break;
            case 2:
               var3 = var1.s();
            }
         }

         int var5;
         if (var4 != null) {
            var5 = this.b.b.getWorksheets().c(var4);
            this.c = this.b.b.getWorksheets().get(var5);
         } else {
            var5 = this.b.b.getWorksheets().add();
            this.c = this.b.b.getWorksheets().get(var5);
         }

         var1.k();
      }

      this.d = new zapz(this.b, this.c);
      com.aspose.cells.b.a.a.ze.a(this.b.n, (Object)this.d);
      zaqe var6 = (zaqe)this.b.m.get(var2);
      if (!var6.b()) {
         this.c.a(false, false);
      }

      if (var6.a() != null) {
         zaqa var7 = (zaqa)this.b.l.get(var6.a());
         if (var7 != null) {
            var7.a(this.c.getPageSetup(), this.b);
         }
      }

      if (var3 != null) {
         this.a(var3);
      }

      if (var1.n()) {
         var1.a();
      } else {
         var1.d();

         while(zass.a(var1)) {
            switch(q.a(var1.p().toLowerCase())) {
            case 3:
               this.e();
               break;
            case 4:
               this.h();
               break;
            case 5:
               this.f();
               break;
            case 6:
               this.c();
               break;
            case 7:
               this.d();
               break;
            case 8:
               this.g();
               break;
            default:
               var1.a();
            }
         }

         this.b();
      }
   }

   private void c() throws Exception {
      if (this.a.n()) {
         this.a.a();
      } else {
         if (this.g == -1) {
            this.g = this.j + 1;
         }

         this.a.d();

         while(zass.a(this.a)) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 3:
               this.e();
               break;
            case 4:
            case 5:
            default:
               this.a.a();
               break;
            case 6:
               this.c();
               break;
            case 7:
               this.d();
            }
         }

         this.h = this.j;
      }
   }

   private void d() throws Exception {
      if (this.a.n()) {
         this.a.a();
      } else {
         this.a.d();

         while(zass.a(this.a)) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 3:
               this.e();
               break;
            case 4:
            case 5:
            default:
               this.a.a();
               break;
            case 6:
               this.c();
               break;
            case 7:
               this.d();
            }
         }

      }
   }

   private void e() throws Exception {
      String var1 = null;
      int var2 = 1;
      String var3 = null;
      if (this.a.m()) {
         while(this.a.l()) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 1:
               var1 = this.a.s();
               break;
            case 9:
               var2 = com.aspose.cells.b.a.zo.a(this.a.s());
               break;
            case 10:
               var3 = this.a.s();
            }
         }
      }

      this.a.a();
      if (var1 == null) {
         this.m += var2;
      } else {
         zaps var4 = (zaps)this.b.f.get(var1);
         if (var4 != null && Math.abs(var4.a() - 64.8D) >= 1.0E-4D) {
            if (this.l.get(var1) == null) {
               this.l.put(var1, var2);
            } else {
               int var5 = (Integer)this.l.get(var1);
               this.l.put(var1, var5 + var2);
            }
         } else {
            this.m += var2;
         }
      }

      zapr var7 = new zapr();
      if (var3 == null) {
         var7.e = this.b.p;
         var7.f = 15;
      } else {
         var7.e = var3;
         Object var8 = this.b.c.get(var3);
         if (var8 != null) {
            Style var6 = this.b.b.getWorksheets().B().a((Integer)var8);
            if (var6.getName() != null && !"".equals(var6.getName())) {
               var7.f = this.b.b.getWorksheets().B().a(var6, (Integer)var8);
            } else {
               var7.f = (Integer)var8;
            }
         }
      }

      var7.b = this.j + 1;
      var7.a = var2;
      this.j += var2;
      com.aspose.cells.b.a.a.ze.a(this.d.c, (Object)var7);
   }

   private void f() throws Exception {
      if (this.a.n()) {
         this.a.a();
      } else {
         if (this.e == -1) {
            this.e = this.i + 1;
         }

         this.a.d();

         while(zass.a(this.a)) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 4:
               this.h();
               break;
            case 5:
               this.f();
               break;
            case 6:
            case 7:
            default:
               this.a.a();
               break;
            case 8:
               this.g();
            }
         }

         this.f = this.i;
      }
   }

   private void g() throws Exception {
      if (this.a.n()) {
         this.a.a();
      } else {
         this.a.d();

         while(zass.a(this.a)) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 4:
               this.h();
               break;
            case 5:
               this.f();
               break;
            case 6:
            case 7:
            default:
               this.a.a();
               break;
            case 8:
               this.g();
            }
         }

      }
   }

   private void h() throws Exception {
      int var1 = this.i();
      int var6;
      if (this.a.n()) {
         this.a.a();
         String var9 = this.b.p;

         for(int var10 = 0; var10 < this.d.c.size(); ++var10) {
            zapr var11 = (zapr)this.d.c.get(var10);
            HashMap var12 = var11.g;
            if (var12.get(var9) != null) {
               var6 = (Integer)((Integer)var12.get(var9));
               var12.put(var9, var6 + var1);
            } else {
               var12.put(var9, var1);
            }
         }

         this.i += var1;
      } else {
         this.j = -1;
         HashMap var2 = new HashMap();
         this.a.d();

         while(zass.a(this.a)) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 11:
            case 12:
               this.a(var2, var1);
               break;
            default:
               this.a.a();
            }
         }

         if (this.j > this.p) {
            this.p = 1023;
         }

         if (var2.size() != 0) {
            String var3 = null;
            int var4 = 0;
            boolean var5 = false;
            if (this.j < this.p) {
               if (var2.get("default") != null) {
                  var6 = (Integer)var2.get("default");
                  var6 += this.p - this.j;
                  var2.put("default", var6);
               } else {
                  var2.put("default", this.p - this.j);
               }
            }

            Iterator var13 = var2.keySet().iterator();

            while(var13.hasNext()) {
               String var7 = (String)var13.next();
               int var8 = (Integer)var2.get(var7);
               if ("default".equals(var7.toLowerCase())) {
                  if (this.j < this.o) {
                     var8 += this.o - this.j + 1;
                  }

                  var5 = true;
               }

               if (var8 > var4) {
                  var4 = var8;
                  var3 = var7;
               }
            }

            if (!var5 && this.j <= this.p && var4 <= this.p - this.j + 1) {
               var3 = null;
            }

            if (var3 != null && !"default".equals(var3.toLowerCase())) {
               zaqv var14 = new zaqv();
               var14.a = this.i + 1;
               var14.b = var1;
               var14.c = var3;
               com.aspose.cells.b.a.a.ze.a(this.d.d, (Object)var14);
            }
         }

         this.i += var1;
      }
   }

   private int i() throws Exception {
      if (this.i == -1) {
         this.o = this.j;
      }

      String var1 = null;
      int var2 = 1;
      if (this.a.m()) {
         while(this.a.l()) {
            switch(q.a(this.a.p().toLowerCase())) {
            case 1:
               var1 = this.a.s();
               break;
            case 13:
               var2 = com.aspose.cells.b.a.zo.a(this.a.s());
            }
         }

         this.a.k();
      }

      if (var1 == null) {
         this.n += var2;
      } else {
         zaqd var3 = (zaqd)this.b.d.get(var1);
         if (var3 != null && Math.abs(var3.b() - 13.68D) >= 1.0E-4D) {
            if (this.k.get(var1) == null) {
               this.k.put(var1, var2);
            } else {
               int var4 = (Integer)this.k.get(var1);
               this.k.put(var1, var4 + var2);
            }
         } else {
            this.n += var2;
         }
      }

      return var2;
   }

   private void a(HashMap var1, int var2) throws Exception {
      int var3 = 1;
      String var4 = null;
      if (this.a.m()) {
         while(true) {
            if (!this.a.l()) {
               this.a.k();
               break;
            }

            switch(q.a(this.a.p().toLowerCase())) {
            case 1:
               var4 = this.a.s();
               break;
            case 9:
               var3 = com.aspose.cells.b.a.zo.a(this.a.s());
            case 14:
            }
         }
      }

      this.a.a();
      String var5 = var4;
      if (var4 == null || com.aspose.cells.b.a.zv.a(var4, "defaut", true) == 0) {
         var5 = "default";
      }

      int var6;
      if (var1.get(var5) != null) {
         var6 = (Integer)((Integer)var1.get(var5));
         var1.put(var5, var6 + var3);
      } else {
         var1.put(var5, var3);
      }

      for(var6 = 0; var6 < var3; ++var6) {
         int var7 = this.j + var6 + 1;
         String var8 = var4;
         zapr var9;
         if (var4 == null) {
            var9 = this.d.d(var7);
            var8 = var9 != null && var9.e != null ? var9.e : this.b.p;
         }

         var9 = this.d.a(var7, var3 - var6);
         HashMap var10 = var9.g;
         if (var10.get(var8) != null) {
            int var11 = (Integer)((Integer)var10.get(var8));
            var10.put(var8, var11 + var2);
         } else {
            var10.put(var8, var2);
         }

         var6 += var9.a - 1;
      }

      this.j += var3;
   }
}
